package gamesolitaire;

import java.awt.*;
import javax.swing.*;


public class Canvas extends JPanel {
	
/**Required for serializable interface*/
private static final long serialVersionUID = 1L;

JPanel panel = new JPanel();
	 
Board gBoard;

	/**constructor new canvas*/
	public Canvas (){
	}
	/**sets the Board that will be drawn*/
	public void setGboard (Board gBoard){
		this.gBoard = gBoard;
	}
	/**Drawing itself*/
	public void paintChildren(Graphics g){
		Graphics g2d = (Graphics) g ;
		//checking if gboard exsist
		if (this.gBoard == null){
			return;
		}
		//Draw Pegs
		g2d.setColor(Color.BLACK);
		for(int row = 0;row < this.gBoard.getRowLength();row++){
			for(int col =0;col< this.gBoard.getColLength();col++){
				//actual drawing
				g2d.drawImage(Peg.getImage(this.gBoard.getCellValue(row, col)), col * Peg.width, row * Peg.height, null);
			}
		}
	}

}

